from django.contrib import admin

# Register your models here.
from celery_tasks.static_html.tasks import generate_static_list_search_html, generate_static_sku_detail_html
from goods import models
from contents.models import Content


class GoodsAdmin(admin.ModelAdmin):
    list_display = ['name', 'brand', 'id']

    def save_model(self, request, obj, form, change):
        obj.save()
        generate_static_list_search_html.delay()

    def delete_model(self, request, obj):
        obj.delete()
        generate_static_list_search_html.delay()


class SUKAdmin(admin.ModelAdmin):
    def save_model(self, request, obj, form, change):
        obj.save()
        generate_static_sku_detail_html.delay(obj.id)


admin.site.register(models.Goods, GoodsAdmin)
admin.site.register(models.SKU)
admin.site.register(Content, SUKAdmin)
